<!DOCTYPE html>

<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8"/>
    <title>转送订单</title>
    <link rel="stylesheet" type="text/css" th:href="@{/layui/css/layui.css}" media="all"/>
    <link rel="stylesheet" type="text/css" th:href="@{/css/news.css}" media="all"/>
</head>
<body class="childrenBody" >
<blockquote class="layui-elem-quote news_search" style="min-width: 1680px;">
    <form id="searchForm" name="searchForm" class="layui-form" action="sendOrderEntry.html">
        <input type="hidden" id="pageNum" name="pageNum" th:value="${page.pageNum}"/>
        <input type="hidden" id="pageSize" name="pageSize" th:value="${page.pageSize}"/>
        <div class="layui-form-item" style="margin-left: -30px;margin-bottom: 2px;">
            <label class="layui-form-label">订单编号:</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" name="orderNo" th:value="${vo.orderNo}"/>
            </div>
            <label class="layui-form-label">用户名:</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" name="userName" th:value="${vo.userName}"/>
            </div>
            <label class="layui-form-label">产品名称:</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" name="productName" th:value="${vo.productName}"/>
            </div>
            <label class="layui-form-label" style="width: 100px;">受赠者用户名:</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" name="toUserName" th:value="${vo.toUserName}"/>
            </div>
        </div>
        <div class="layui-form-item" style="margin-left: -30px;margin-bottom: 2px;margin-top: 12px;">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-inline">
                <select name="orderState" lay-filter="status">
                    <option value="">选择查询转送状态</option>
                    <option value="3" th:selected="${vo}ne null  and ${vo.orderState == 3}">送出待接收</option>
                    <option value="4" th:selected="${vo}ne null  and ${vo.orderState == 4}">已退回</option>
                    <option value="5" th:selected="${vo}ne null  and ${vo.orderState == 5}">送出成功</option>
                    <option value="6" th:selected="${vo}ne null  and ${vo.orderState == 6}">领取成功</option>
                </select>
            </div>
            <label class="layui-form-label">创建时间:</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" name="startTime" id="startTime" readonly="readonly"
                       th:value="${vo.startTime}?${#dates.format(vo.startTime, 'yyyy-MM-dd HH:mm:ss')}"/>
            </div>
            <div class="layui-form-mid">-</div>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" name="endTime" id="endTime" readonly="readonly"
                       th:value="${vo.endTime}?${#dates.format(vo.endTime, 'yyyy-MM-dd HH:mm:ss')}"/>
            </div>
            <button class="layui-btn search_btn"><i class="layui-icon">&#xe615;</i>查询</button>
            <!--<a class="layui-btn layui-btn-normal newsAdd_btn" id="add"><i class="layui-icon">&#xe608;</i>添加</a>-->
            <a class="layui-btn excel_btn"><i class="layui-icon">&#xe615;</i>导出</a>
        </div>
    </form>
</blockquote>
<div class="layui-form news_list" style="min-width: 1680px;">
    <table class="layui-table">
        <thead>
        <tr>
            <th>订单编号</th>
            <th>用户OpenId</th>
            <th>用户名</th>
            <th>产品编号</th>
            <th>产品名称</th>
            <th>产品金额</th>
            <!--<th>受赠用户OpenId</th>-->
            <th>转送至用户名</th>
            <th>状态</th>
            <th>赠送时间</th>
            <th>接收时间</th>
            <th>回滚时间</th>
        </tr>
        </thead>
        <tbody class="news_content">
        <th:block th:if="${not #lists.isEmpty(page.list)}">
            <tr th:each="item:${page.list}">
                <td th:text="${item.orderNo}"></td>
                <td th:text="${item.openId}"></td>
                <td th:text="${item.fromUserNickName}"></td>
                <td th:text="${item.productCode}"></td>
                <td th:text="${item.productName}"></td>
                <td th:text="${item.buyAmount}"></td>
                <td th:text="${item.toUserNickName}"></td>
                <th:block th:switch="${item.orderStatus}">
                    <td th:case="3" style="color: #e47214">送出待接收</td>
                    <td th:case="4" style="color: #ff0000">已退回</td>
                    <td th:case="5" style="color: #008000">送出成功</td>
                    <td th:case="6" style="color: #01AAED">领取成功</td>
                </th:block>
                <th:block th:if="${item.orderStatus eq 3}">
                    <td th:text="${item.sentTime}?${#dates.format(item.sentTime,'yyyy-MM-dd HH:mm:ss')}:''"></td>
                    <td></td>
                    <td></td>
                </th:block>
                <th:block th:if="${item.orderStatus eq 4}">
                    <td th:text="${item.sentTime}?${#dates.format(item.sentTime,'yyyy-MM-dd HH:mm:ss')}:''"></td>
                    <td></td>
                    <td th:text="${item.backTime}?${#dates.format(item.backTime,'yyyy-MM-dd HH:mm:ss')}:''"></td>
                </th:block>
                <th:block th:if="${item.orderStatus eq 5}">
                    <td th:text="${item.sentTime}?${#dates.format(item.sentTime,'yyyy-MM-dd HH:mm:ss')}:''"></td>
                    <td th:text="${item.receiveTime}?${#dates.format(item.receiveTime,'yyyy-MM-dd HH:mm:ss')}:''"></td>
                    <td></td>
                </th:block>
                <th:block th:if="${item.orderStatus eq 6}">
                    <td></td>
                    <td th:text="${item.createTime}?${#dates.format(item.createTime,'yyyy-MM-dd HH:mm:ss')}:''"></td>
                    <td></td>
                </th:block>
            </tr>
        </th:block>
        </tbody>
    </table>
</div>
<div id="paged" align="right"></div>
<script type="text/javascript" th:src="@{/layui/layui.js}"></script>
<script type="text/javascript" th:src="@{/jquery/jquery-3.2.1.min.js}"></script>
</body>
<script th:inline="javascript">
    layui.use(['laypage', 'laydate','form'], function () {
        var laypage = layui.laypage, $ = layui.jquery;
        //执行一个laypage实例
        laypage.render({
            elem: 'paged', //注意，这里的 test1 是 ID，不用加 # 号
            curr: [[${page.pageNum}]],
            count: [[${page.total}]], //数据总数，从服务端得到
            limit: [[${page.pageSize}]],
            layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'],
            jump: function (obj, first) {
                //得到了当前页，用于向服务端请求对应数据
                var curr = obj.curr;
                var limit = obj.limit;
                $("#pageSize").val(limit);
                $("#pageNum").val(curr);
                if (!first) {
                    $("#searchForm").submit();
                }
            }
        });
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#startTime' //指定元素
            , type: 'datetime'
            , format: 'yyyy-MM-dd HH:mm:ss'
            , max: 1
        });
        //执行一个laydate实例
        laydate.render({
            elem: '#endTime' //指定元素
            , type: 'datetime'
            , format: 'yyyy-MM-dd HH:mm:ss'
            , max: 1
        });
        var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
        //但是，如果你的HTML是动态生成的，自动渲染就会失效
        //因此你需要在相应的地方，执行下述方法来手动渲染，跟这类似的还有 element.init();
        form.render();
        //导出excel
        $(".excel_btn").bind("click", function () {
            location.href = '/order/sendOrderExcel?' + $("#searchForm").serialize();
        });
    });

</script>
</html>